package com.gzy.rpsm_admin.controller;

import com.gzy.rpsm_admin.pojo.Building;
import com.gzy.rpsm_admin.pojo.PageResult;
import com.gzy.rpsm_admin.pojo.ResponsePojo;
import com.gzy.rpsm_admin.service.BuildingService;
import io.swagger.annotations.*;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Api(tags = "楼栋相关接口")

public class BuildingController {

    @Autowired
    private BuildingService buildingService;

    @ApiOperation(value = "查询楼栋分页信息",
            response = Building.class,
            responseContainer = "list",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "current", value = "当前页数 "
                    , defaultValue = "1", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "页面行数 "
                    , dataType = "Integer", paramType = "query", defaultValue = "10"),
    })
    @GetMapping("/page/building")
    public ResponsePojo<PageResult<Building> > pageOfBuilding(
            @RequestParam(defaultValue = "1") Integer current,
            String number,
            @RequestParam(defaultValue = "10") Integer size) {
        PageResult<Building> result =
                buildingService.PageOfBuilding(current,size,number);
        return ResponsePojo.success(result);
    }
}
